package LeetCode;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}17:58
 */
public class interview67 {

      public class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode(int x) { val = x; }
  }

    public static void main(String[] args) {

    }
    public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
        if (root == null){
            return root;
        }
        if (p.val > root.val && q.val > root.val){
            lowestCommonAncestor(root.right,p,q);
        }else if (p.val < root.val && q.val < root.val){
            lowestCommonAncestor(root.left,p,q);
        }
        return root;
    }
}
